<%--
  Created by IntelliJ IDEA.
  User: feng
  Date: 2023/5/12
  Time: 11:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>体育馆管理系统</title>
    <meta name="description" content="体育馆管理系统">
    <meta name="keywords" content="体育馆管理系统">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="<%=request.getContextPath()%>/resources/plugins/elementui/index.css">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/resources/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/resources/css/style.css">
    <!-- 引入组件库 -->
    <script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/jquery.min.js"></script>
    <script src="<%=request.getContextPath()%>/resources/js/vue.js"></script>
    <script src="<%=request.getContextPath()%>/resources/plugins/elementui/index.js"></script>
    <script src="<%=request.getContextPath()%>/resources/js/axios-0.18.0.js"></script>
    <style>
        .datatable {
            position: relative;
            box-sizing: border-box;
            -webkit-box-flex: 1;
            width: 100%;
            max-width: 100%;
            font-size: 14px;
            color: rgb(96, 98, 102);
            overflow: hidden;
            flex: 1 1 0%;
        }
        .datatable td, .datatable th {
            padding: 12px 0;
            min-width: 0;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            text-overflow: ellipsis;
            vertical-align: middle;
            position: relative;
            text-align: left;
        }
    </style>
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header">
        <h1>个人信息<small>个人信息</small></h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>个人信息</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <div class="app-container">
        <div class="box">
            <el-tabs v-model="activeName" type="card">
                <el-tab-pane label="个人信息" name="first">
                    <el-form label-position="right" label-width="100px">
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="账号">
                                    <el-input  v-model="formData.userNo" :disabled="isDisabled"/>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="姓名">
                                    <el-input  v-model="formData.realName" :disabled="isDisabled"/>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="呢称">
                                    <el-input v-model="formData.userName" :disabled="isDisabled"/>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="余额">
                                    <el-input v-model="formData.userBalance" :disabled="isDisabled"/>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="职位">
                                    <el-select v-model="formData.userRole" placeholder="请选职位" :disabled="isDisabled"/>
                                        <el-option label="超级管理员" value="超级管理员"></el-option>
                                        <el-option label="场地管理员" value="场地管理员"></el-option>
                                        <el-option label="赛事管理员" value="赛事管理员"></el-option>
                                        <el-option label="器材管理员" value="器材管理员"></el-option>
                                        <el-option label="场地管理员" value="场地管理员"></el-option>
                                        <el-option label="公告管理员" value="公告管理员"></el-option>
                                        <el-option label="系统管理员" value="系统管理员"></el-option>
                                        <el-option label="教职工" value="教职工"></el-option>
                                        <el-option label="学生" value="学生"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="6">
                                <el-form-item label="电话">
                                    <el-input v-model="formData.telephone" :disabled="isDisabled"/>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>

                </el-tab-pane>
            </el-tabs>
            <div slot="footer" class="dialog-footer">
                <el-button v-if="isDisabled" type="primary" @click="handleUpdate()">修改</el-button>
                <el-button v-if="isDisabledLater" type="primary" @click="handleUpdateLater()">取消修改</el-button>
                <el-button v-if="isDisabledLater" type="primary" @click="handleUpdateTure()">确认修改</el-button>
            </div>
        </div>
    </div>
</div>

<script>
</script>

</body>

<script>
    var vue = new Vue({
        el: '#app',
        data:{
            activeName:'first',//添加/编辑窗口Tab标签名称
            pagination: {//分页相关属性
                pageNow: 1,
                pageSize:10,
                total:100,
                queryString:null,
            },
            dataList: [],//列表数据
            formData: {},//表单数据
            tableData:[],//新增和编辑表单中对应的检查项列表数据
            checkitemIds:[],//新增和编辑表单中检查项对应的复选框，基于双向绑定可以进行回显和数据提交
            dialogFormVisible: false,//控制添加窗口显示/隐藏
            dialogFormVisible4Edit:false,//控制编辑窗口显示/隐藏
            isDisabled:true,//输入框是否可输入
            isDisabledLater:false//输入框是否可输入
        },
        created() {

            this.findPage();
        },
        methods: {
            //分页查询
            findPage() {
                this.formData.userNo = JSON.parse(JSON.stringify("${userMess.userNo}"));
                this.formData.realName = "${userMess.realName}";
                this.formData.userName = "${userMess.userName}";
                this.formData.userPassword = "${userMess.userPassword}";
                this.formData.userRole = "${userMess.userRole}";
                this.formData.telephone = "${userMess.telephone}";
                this.formData.permissionID = "${userMess.permissionID}";
                this.formData.recordRemark = "${userMess.recordRemark}";
                this.formData.userBalance = "${userMess.userBalance}";
                localStorage.setItem('obj', JSON.stringify(this.formData));
                this.formData = JSON.parse(localStorage.getItem('obj'));
            },
            // 重置表单
            resetForm() {
                this.formData = {};
            },

            //点击修改
            handleUpdate() {
                localStorage.setItem('formData', JSON.stringify(this.formData));
                this.isDisabled = false;
                this.isDisabledLater = true;
            },

            //取消修改
            handleUpdateLater() {
                this.formData = JSON.parse(localStorage.getItem('formData'));
                this.isDisabled = true;
                this.isDisabledLater = false;
            },

            handleUpdateTure() {
                axios.post("<%=request.getContextPath()%>/record/change.do",this.formData).then((response)=> {
                    //隐藏编辑窗口
                    this.dialogFormVisible4Edit = false;
                    if(response.data.success){
                        this.$message({
                            message: response.data.data,
                            type: 'success'
                        });
                    }else{
                        this.$message.error(response.data.data);
                    }
                }).finally(()=> {
                    var param = {
                        userNo:this.formData.userNo//查询条件
                    };
                    axios.post("<%=request.getContextPath()%>/record/find.do",param).then((res)=>{
                        if(res.data.data.rows.length === 1){
                            //弹出编辑窗口
                            this.dialogFormVisible4Edit = true;
                            //为模型数据赋值，通过VUE数据双向绑定进行信息的回显
                            this.formData={};
                            console.log(res.data.data.rows[0]);
                            this.formData = res.data.data.rows[0];
                        }else{
                            this.$message.error("获取数据失败，请刷新当前页面");
                        }
                    });
                });
                this.isDisabled = true;
                this.isDisabledLater = false;
            },
        }
    })
</script>
</html>
